package org.androidpn.activity;

import org.androidpn.R;
import org.androidpn.model.CTalkMessage;
import org.androidpn.utils.ConstanceUtil;

import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.view.Window;
import android.widget.ImageView;

public class ShowPicActivity extends Activity {
	private ImageView ivContent;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.showimageactivity);
		CTalkMessage cTalkMessage = (CTalkMessage) getIntent().getSerializableExtra("ctalkmessage");
		ivContent = (ImageView) findViewById(R.id.iv_content);
		DisplayImageOptions options1 = new DisplayImageOptions.Builder().cacheInMemory(true).cacheOnDisk(true)
				.considerExifParams(true).bitmapConfig(Bitmap.Config.RGB_565).showImageOnFail(R.drawable.loading_defalt)
				.showImageForEmptyUri(R.drawable.loading_defalt).showImageOnLoading(R.drawable.loading_defalt).build();

		if (!cTalkMessage.isLocaldata) {
			String imgurl = ConstanceUtil.HOST_NAME + cTalkMessage.getMessage_content();
			ImageLoader.getInstance().displayImage(imgurl, ivContent, options1);

		} else {
			ImageLoader.getInstance().displayImage("file://" + cTalkMessage.getMessage_content(), ivContent);
		}
	}
}
